package com.yy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yy.entity.ParkingLot;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface ParkingLotMapper extends BaseMapper<ParkingLot> {
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "pricing_standard_id",property = "pricingStandard",one=@One(select = "com.yy.mapper.PricingStandardMapper.selectById")),

    })
    @Select("select * from parking_lot join pricing_standard  " +
            "on pricing_standard.id=parking_lot.pricing_standard_id ")
    List<ParkingLot> getAll();
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "pricing_standard_id",property = "pricingStandard",one=@One(select = "com.yy.mapper.PricingStandardMapper.selectById")),
    })
    @Select("select * from parking_lot join pricing_standard " +
            "on pricing_standard.id=parking_lot.pricing_standard_id "+
            "where parking_lot.id=#{parking_lot.id} ")
    ParkingLot getById(Long id);

    @Insert("insert into parking_lot set name=#{name} "+
            ",volumetric=#{volumetric} "+
            ",pricing_standard_id=#{pricingStandard.id} ")
    int insert(ParkingLot entity);
    @Update("update parking_lot set name=#{name} "+
            ",volumetric=#{volumetric} "+
            ",pricing_standard_id=#{pricingStandard.id} ")
    int update(ParkingLot entity);
}
